package asteroids.model.programs.parsing;

import java.util.List;

import asteroids.model.programs.parsing.expressions.*;
import asteroids.model.programs.parsing.types.*;
import asteroids.model.programs.parsing.statements.*;


public class ProgramFactoryImpl implements ProgramFactory<E,S,T>{

	@Override
	public E createDoubleLiteral(int line, int column, double d) {
		return new DoubleLiteral(d);
	}

	@Override
	public E createBooleanLiteral(int line, int column, boolean b) {
		return new BooleanLiteral(b);
	}

	@Override
	public E createAnd(int line, int column, E e1, E e2) {
		return new And(e1, e2);
	}

	@Override
	public E createOr(int line, int column, E e1, E e2) {
		return new Or(e1, e2);
	}

	@Override
	public E createNot(int line, int column, E e) {
		return new Not(e);
	}

	@Override
	public E createNull(int line, int column) {
		return new Null();
	}

	@Override
	public E createSelf(int line, int column) {
		//Ship ship = program.getShip();
		//return new Self(ship);
		//TODO
		return new Self();
	}

	@Override
	public E createGetX(int line, int column, E e) {
		return new GetX(e);
	}

	@Override
	public E createGetY(int line, int column, E e) {
		return new GetY(e);
	}

	@Override
	public E createGetVX(int line, int column, E e) {
		return new GetVX(e);
	}

	@Override
	public E createGetVY(int line, int column, E e) {
		return new GetVY(e);
	}

	@Override
	public E createGetRadius(int line, int column, E e) {
		return new GetRadius(e);
	}

	@Override
	public E createVariable(int line, int column, String name) {
		return new asteroids.model.programs.parsing.expressions.Variable(name);
	}

	@Override
	public E createLessThan(int line, int column, E e1, E e2) {
		return new LessThan(e1, e2);
	}

	@Override
	public E createGreaterThan(int line, int column, E e1, E e2) {
		return new GreaterThan(e1, e2);
	}

	@Override
	public E createLessThanOrEqualTo(int line, int column, E e1, E e2) {
		return new LessThanOrEqualTo(e1, e2);
	}

	@Override
	public E createGreaterThanOrEqualTo(int line, int column, E e1, E e2) {
		return new GreaterThanOrEqualTo(e1, e2);
	}

	@Override
	public E createEquality(int line, int column, E e1, E e2) {
		return new Equality(e1, e2);
	}

	@Override
	public E createInequality(int line, int column, E e1, E e2) {
		return new Inequality(e1, e2);
	}

	@Override
	public E createAdd(int line, int column, E e1, E e2) {
		return new Add(e1, e2);
	}

	@Override
	public E createSubtraction(int line, int column, E e1, E e2) {
		Substraction substraction =new Substraction(e1, e2);
		return substraction;
	}

	@Override
	public E createMul(int line, int column, E e1, E e2) {
		return new Multiplication(e1, e2);
	}

	@Override
	public E createDivision(int line, int column, E e1, E e2) {
		return new Division(e1, e2);
	}

	@Override
	public E createSqrt(int line, int column, E e) {
		return new Sqrt(e);
	}

	@Override
	public E createGetDirection(int line, int column) {
		E e = createSelf(line, column);
		return new GetDirection(e);
	}

	@Override
	public E createSin(int line, int column, E e) {
		return new Sin(e);
	}

	@Override
	public E createCos(int line, int column, E e) {
		return new Cos(e);
	}

	@Override
	public S createEnableThruster(int line, int column) {
		return new Thrust(line, column, true);
	}

	@Override
	public S createDisableThruster(int line, int column) {
		return new Thrust(line, column, false);
	}

	@Override
	public S createFire(int line, int column) {
		return new Fire(line,column);
	}

	@Override
	public S createTurn(int line, int column, E angle) {
		return new Turn(line,column,angle);
	}

	@Override
	public S createAssignment(int line, int column, String variable, E rhs) {
		return new Assignment(line, column, variable, rhs);
	}

	@Override
	public S createIf(int line, int column, E condition, S then, S otherwise) {
		return new IfThenElse(line, column, condition, then, otherwise);
	}

	@Override
	public S createWhile(int line, int column, E condition, S body) {
		return new WhileLoop(line, column, condition, body);
	}

	@Override
	public S createForeach(int line, int column,ForeachType type, String variableName, S body) {
		//TODO bijwerken (execute)

		return new ForEachLoop(line, column, type, variableName, body);
	}

	@Override
	public S createSkip(int line, int column) {
		return new Skip(line, column);
	}

	@Override
	public S createSequence(int line, int column, List<S> statements) {
		return new Sequence(line,column,statements);
	}

	@Override
	public S createPrint(int line, int column, E e) {
		return new Print(line, column, e);
	}

	@Override
	public T createDoubleType() {
		return new DoubleType();
	}

	@Override
	public T createBooleanType() {
		return new BoolType();
	}

	@Override
	public T createEntityType() {
		return new EntityType();
	}

}
